﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Pg.BioMedics.SDR.Entities;
using Pg.BioMedics.SDR.Entities.Codes;

namespace Pg.BioMedics.SDR.Caching
{
    /// <summary>
    /// Provides strongly typed cache functionality for Document entities
    /// </summary>
    public class DocumentCache : BaseCache<Document>
    {       
        #region Constructors

        /// <summary>
        /// Creates instance of the DocumentCache with the given caching strategy.
        /// </summary>
        /// <param name="cachingStrategy">Caching strategy</param>
        internal DocumentCache(ICachingStrategy<Document> cachingStrategy)
            : base(cachingStrategy) { }

        #endregion

        #region Overriden methods

        /// <summary>
        /// Gets Document key value utilized to distinguish items 
        /// in the document cache
        /// </summary>
        /// <param name="item">Document instance</param>
        /// <returns>Key value</returns>
        public override string GetKey(Document item)
        {
            return item.Id.HasValue ? item.Id.Value.ToString() : null;
        }

        #endregion        
    }
}
